package com.jinlia.show.modules.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jinlia.show.modules.base.model.form.MemberCardForm;
import com.jinlia.show.modules.base.system.entity.MemberCard;
import com.jinlia.show.modules.base.model.po.MemberCardPO;
import com.jinlia.show.modules.base.model.query.MemberCardQuery;
import com.jinlia.show.modules.base.system.service.MemberCardMapperService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/member")
public class MemberCardController {
    final MemberCardMapperService memberCardMapperService;

    //(summary = "用户分页列表")
    @PostMapping("/page")
    public ResponseEntity<IPage<MemberCardPO>> getPage(@RequestBody MemberCardQuery queryParams) {
        IPage<MemberCardPO> tt = memberCardMapperService.getPage(queryParams);
        return ResponseEntity.ok(tt);
    }

    @GetMapping("{id}")
    public ResponseEntity<MemberCard> getById(@PathVariable(value = "id") Long id) {
        return ResponseEntity.ok(memberCardMapperService.getById(id));
    }

    /**
     * 调整余额
     */
    @PostMapping("/update")
    public ResponseEntity<MemberCard> getPage(@RequestBody MemberCardForm memberCardForm) {
        MemberCard tt = memberCardMapperService.updateMemberCard(memberCardForm);
        return ResponseEntity.ok(tt);
    }

    @PostMapping("/list")
    public List<MemberCardPO> list(@RequestBody MemberCardForm memberCardForm) {

        return memberCardMapperService.listMember(memberCardForm);
    }
}
